﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Csharp虚方法
{

    //真的鸭子嘎嘎叫,木头鸭子吱吱叫,橡皮鸭子唧唧叫
    //把这三个鸭子类抽象出一个父类
    //用虚方法去父类写一个叫的方法父类叫的方法中要输出这是父类的叫
    class duck
    {
        public string name;
        //public duck(string name) 
        //{
        //    this.name = name;
        //}

        public virtual void duckSHow() 
        {
            Console.WriteLine("这个是父类的叫");
        }
    }


    class realduck : duck 
    {
        //public realduck(string name) : base(name) { }
        public override void duckSHow()
        {
            Console.WriteLine("{0}嘎嘎叫",name);
        }
    }

    class woodduck : duck 
    {
        //public woodduck(string name) : base(name) { }

        public override void duckSHow()
        {
            Console.WriteLine("{0}吱吱叫", name);
        }

    }


    class xiangpiduck : duck
    {
        //public xiangpiduck(string name) : base(name) { }

        public override void duckSHow()
        {
            Console.WriteLine("{0}叽叽叫", name);
        }

    }

}
